package file;

import javafx.application.Application;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class Main extends Application {
    private static boolean answer;

    public static void main(String[] args) {

        launch(args);

    }

    /**
     * @param title 标题
     * @param msg   消息
     */
    public static boolean display(String title, String msg) {
        // 创建舞台
        Stage stage = new Stage();

        // 设置显示模式
        stage.initStyle(StageStyle.UNDECORATED);
        stage.initModality(Modality.APPLICATION_MODAL);
        class _EventHandler implements EventHandler<MouseEvent> {
            private Button source;

            @Override
            public void handle(MouseEvent event) {
                source = (Button) event.getSource();
                stage.close();
            }
        }
        _EventHandler handler = new _EventHandler();
        // 创建控件
        Button buttonYes = new Button("是");
        buttonYes.setOnMouseClicked(handler);

        Button buttonNo = new Button("否");
        buttonNo.setOnMouseClicked(handler);

        Label label = new Label(msg);

        // 创建布局
        VBox vBox = new VBox();
        vBox.getChildren().addAll(label, buttonYes, buttonNo);
        vBox.setAlignment(Pos.CENTER); // 布局居中显示

        // 创建场景
        Scene scene = new Scene(vBox, 200, 200);

        // 显示舞台
        stage.setScene(scene);
        stage.setFullScreen(true);
        stage.setFullScreenExitHint("巴拉拉吧");
        stage.showAndWait();  // 等待窗体关闭才继续
        // 窗体返回值
        return handler.source == buttonYes;
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        System.out.println(display("12", "233"));
    }
}

